<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>用户管理 | {$system_name}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="{_ADMIN_STATIC_}/i/favicon.png">
    <link rel="stylesheet" href="{_ADMIN_STATIC_}/css/amazeui.min.css" />
    <link rel="stylesheet" href="{_ADMIN_STATIC_}/css/admin.css">
    <link rel="stylesheet" href="{_ADMIN_STATIC_}/css/app.css">

</head>

<body data-type="index">
    <!-- 头部导航栏 -->
    {include file='public/header'}
    <!-- 左侧侧边栏 -->
    {include file='public/side'}
    <!-- 中间内容开始 -->

    <!-- 标题 -->
    <div class="tpl-content-page-title">
        {$system_name} -- 用户管理
    </div>
    <!-- 面包屑导航 -->
    <ol class="am-breadcrumb">
        <li><a href="{:url('User/index')}" class="am-icon-home">用户管理</a></li>
        <li>用户编辑</li>
    </ol>
    <!-- 提示信息 -->
    <div class="tpl-content-scope">
        <div class="note note-info">
            <h3> 用户编辑
                <span class="close" data-close="note"></span>
            </h3>
            <p>用户编辑</p>
            <p><span class="label label-danger">提示:</span>
                编辑某一个具体的用户的所有信息
            </p>
        </div>

        <div class="tpl-portlet-components">

            <div class="tpl-block ">
                <div class="am-g tpl-amazeui-form">

                    <div class="am-u-sm-12 am-u-md-9">
                        <div class="am-form am-form-horizontal">
                            <div class="am-form-group">
                                <label for="account" class="am-u-sm-3 am-form-label">账号 / Account</label>
                                <div class="am-u-sm-9">
                                    <input type="text" id="account" value="{$user_info.account}"
                                        placeholder="账号 / Account" disabled>
                                    <small></small>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="name" class="am-u-sm-3 am-form-label">姓名 / Name</label>
                                <div class="am-u-sm-9">
                                    <input type="text" id="name" placeholder="姓名 / Name" value="{$user_info.name}">
                                    <small></small>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label for="age" class="am-u-sm-3 am-form-label">年龄 / Age</label>
                                <div class="am-u-sm-9">
                                    <input type="text" id="age" placeholder="年龄 / Age" value="{$user_info.age}">
                                    <small></small>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label for="position" class="am-u-sm-3 am-form-label">职务 / Position</label>
                                <div class="am-u-sm-9">
                                    <input type="text" id="position" placeholder="职务 / Position"
                                        value="{$user_info.position}">
                                    <small></small>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label for="tel" class="am-u-sm-3 am-form-label">办公室电话 / Tel</label>
                                <div class="am-u-sm-9">
                                    <input type="text" id="tel" placeholder="办公室电话 / Tel" value="{$user_info.tel}">
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label for="phone" class="am-u-sm-3 am-form-label">手机 / Phone</label>
                                <div class="am-u-sm-9">
                                    <input type="number" pattern="[0-9]*" id="phone" placeholder="手机 / Phone"
                                        value="{$user_info.phone}">
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label for="email" class="am-u-sm-3 am-form-label">电子邮件 / Email</label>
                                <div class="am-u-sm-9">
                                    <input type="text" id="email" placeholder="电子邮件 / Email" value="{$user_info.email}">
                                </div>
                            </div>


                            <div class="am-form-group">
                                <label for="qq" class="am-u-sm-3 am-form-label">QQ</label>
                                <div class="am-u-sm-9">
                                    <input type="number" pattern="[0-9]*" id="qq" placeholder="输入你的QQ号码"
                                        value="{$user_info.qq}">
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label for="wx" class="am-u-sm-3 am-form-label">微信</label>
                                <div class="am-u-sm-9">
                                    <input type="text" id="wx" placeholder="微信" value="{$user_info.wx}">
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label for="address" class="am-u-sm-3 am-form-label">办公室地址 / Address</label>
                                <div class="am-u-sm-9">
                                    <input type="text" id="address" placeholder="办公室地址 / Address"
                                        value="{$user_info.address}">
                                    <small></small>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <div class="am-u-sm-3 am-u-sm-push-3">
                                    <button type="button" class="am-btn am-btn-primary" onclick="save()">保存修改</button>
                                </div>
                                <div class="am-u-sm-6 am-u-sm-push-3">
                                    <button type="button" class="am-btn am-btn-primary"
                                        onclick="re_password('{$user_info.id}')">重置密码</button>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>


    <!-- 中间内容结束 -->
    <!-- 底部 -->
    <!-- {include file="public/footer"} -->

    <script src="{_ADMIN_STATIC_}/lib/jquery/jquery.js"></script>
    <script src="{_ADMIN_STATIC_}/js/amazeui.min.js"></script>
    <script src="{_ADMIN_STATIC_}/js/app.js"></script>
    <script src="{_ADMIN_STATIC_}/lib/layer/layer.js"></script>
    <script>

        // 保存修改
        function save() {

            // ID
            var id = "{$user_info.id}";
            // 姓名
            var name = $('#name').val().trim();
            // 年龄
            var age = $('#age').val().trim();
            // 职务
            var position = $('#position').val().trim();
            // 办公室电话
            var tel = $('#tel').val().trim();
            // 手机
            var phone = $('#phone').val().trim();
            // 邮箱
            var email = $('#email').val().trim();
            // QQ
            var qq = $('#qq').val().trim();
            // 微信
            var wx = $('#wx').val().trim();
            // 办公室地址
            var address = $('#address').val().trim();

            var data = {
                'id': id,
                'name': name,
                'age': age,
                'position': position,
                'tel': tel,
                'phone': phone,
                'email': email,
                'qq': qq,
                'wx': wx,
                'address': address,
            };

            $.ajax({
                url: "{:url('User/user_edit')}",
                data: data,
                type: "POST",
                dataType: "JSON",
                success: function (res) {
                    // 返回结果处理
                    if (res.code == 0) {
                        return layer.msg(res.msg, { icon: 1, time: 900 });
                    } else {
                        return layer.msg(res.msg, { icon: 2, time: 900 });
                    }
                }
            });

        }

        // 重置密码
        function re_password($id) {
            layer.confirm('确定要重置密码?', {
                btn: ['是', '否'] //按钮
            }, function () {
                $.ajax({
                    url: "{:url('User/re_password')}",
                    data: {
                        'uid': $id
                    },
                    type: "POST",
                    dataType: "JSON",
                    success: function (res) {
                        if (res.code == 0) {
                            return layer.msg(res.msg, { icon: 1, time: 900 });
                        } else {
                            return layer.msg(res.msg, { icon: 2, time: 900 });
                        }
                    }
                });
            }, function () { });
        }

        // 重定向
        function redirect_url(url) {
            window.location.href = url;
        }

    </script>
</body>

</html>